package com.baizhi.service.Impl;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.T_user;
import com.baizhi.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserDao, T_user> implements UserService {

    @Autowired
    UserDao userDao;


    @Transactional(propagation = Propagation.SUPPORTS)
    public T_user login(T_user user) {

        LambdaQueryWrapper<T_user> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(T_user::getUsername, user.getUsername());
        queryWrapper.eq(T_user::getPassword, user.getPassword());

        T_user obj = this.getOne(queryWrapper);

        return obj;
    }
}
